package serclet;

import Serice.impl.xtyhSericeImpl;
import Serice.xtyhSerice;
import com.alibaba.fastjson.JSON;
import entity.Xtyh;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

@WebServlet(urlPatterns = "/cx")
public class Cx extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       req.setCharacterEncoding("utf-8");
       resp.setCharacterEncoding("utf-8");
        xtyhSerice xt=new xtyhSericeImpl();
        try {
            List<Xtyh> list=xt.getXtyhDao();
            PrintWriter ou=resp.getWriter();
            ou.println(JSON.toJSONString(list));
            ou.flush();
            ou.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
